package com.bill.common.system.action;

import com.bill.common.system.dao.EmailMessageQueryDTO;
import com.bill.common.system.dto.EmailMessageDTO;
import com.bill.common.system.service.IEmailService;
import com.opensymphony.xwork2.ActionSupport;
import com.sinba.common.dto.PageDTO;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * 邮件Action�?
 * @author tan
 */
@SuppressWarnings( "serial" )
public class EmailAction
    extends ActionSupport
{
    private EmailMessageDTO emailMessageDto = new EmailMessageDTO(  );
    private boolean result = false;
    private int testErrorEncode = 0;
    private PageDTO emailDtos;
    private int page = 1;
    private int rows = 10;
    private long eid = 0;
    private Long[] ids;
    private EmailMessageQueryDTO emailMessageQueryDto;
    private String sidx;
    private String sord;
    private String loginName;
    private String title;
    private String content;
    @Autowired
    private IEmailService emailService;
    private String emailType;

    public String getEmailType(  )
    {
        return emailType;
    }

    public void setEmailType( String emailType )
    {
        this.emailType = emailType;
    }

    public String getSidx(  )
    {
        return sidx;
    }

    public void setSidx( String sidx )
    {
        this.sidx = sidx;
    }

    public String getSord(  )
    {
        return sord;
    }

    public void setSord( String sord )
    {
        this.sord = sord;
    }

    public PageDTO getEmailDtos(  )
    {
        return emailDtos;
    }

    public void setEmailDtos( PageDTO emailDtos )
    {
        this.emailDtos = emailDtos;
    }

    public boolean isResult(  )
    {
        return result;
    }

    public void setResult( boolean result )
    {
        this.result = result;
    }

    public int getPage(  )
    {
        return page;
    }

    public void setPage( int page )
    {
        this.page = page;
    }

    public int getRows(  )
    {
        return rows;
    }

    public void setRows( int rows )
    {
        this.rows = rows;
    }

    public int getTestErrorEncode(  )
    {
        return testErrorEncode;
    }

    public void setTestErrorEncode( int testErrorEncode )
    {
        this.testErrorEncode = testErrorEncode;
    }

    public EmailMessageDTO getEmailMessageDto(  )
    {
        return emailMessageDto;
    }

    public void setEmailMessageDto( EmailMessageDTO emailMessageDto )
    {
        this.emailMessageDto = emailMessageDto;
    }

    public long getEid(  )
    {
        return eid;
    }

    public void setEid( long eid )
    {
        this.eid = eid;
    }

    public EmailMessageQueryDTO getEmailMessageQueryDto(  )
    {
        return emailMessageQueryDto;
    }

    public void setEmailMessageQueryDto( EmailMessageQueryDTO emailMessageQueryDto )
    {
        this.emailMessageQueryDto = emailMessageQueryDto;
    }

    public Long[] getIds(  )
    {
        return ids;
    }

    public void setIds( Long[] ids )
    {
        this.ids = ids;
    }

    public String getLoginName(  )
    {
        return loginName;
    }

    public void setLoginName( String loginName )
    {
        this.loginName = loginName;
    }

    public String getTitle(  )
    {
        return title;
    }

    public void setTitle( String title )
    {
        this.title = title;
    }

    public String getContent(  )
    {
        return content;
    }

    public void setContent( String content )
    {
        this.content = content;
    }

    /**
    * 获取邮件
    * @return String
    */
    public String findEmail(  )
    {
        int start = ( page - 1 ) * rows;
        emailDtos = emailService.getEmailMessage( emailMessageQueryDto, start, rows, sidx, sord );
        emailDtos.setPage( page );
        emailDtos.setRows( rows );

        return "showall";
    }

    /**
    * to email    写Email
    * @return String
    * @throws Exception
    */
    public String toEmail(  )
                   throws Exception
    {
//        result = emailService.sendMail();
        return "result";
    }

    public String deleteEmail(  )
    {
        emailService.deleteEmail( ids );
        emailMessageQueryDto = new EmailMessageQueryDTO(  );
        emailMessageQueryDto.setToUser( loginName );

        int start = ( page - 1 ) * rows;
        emailDtos = emailService.getEmailMessage( emailMessageQueryDto, start, rows, sidx, sord );
        emailDtos.setPage( page );
        emailDtos.setRows( rows );

        return "showall";
    }
}
